<?php
/**
 * 检查列表页面Josn
 * Created by PhpStorm.
 * User: zhang-hong
 * Date: 2017/3/7
 * Time: 16:05
 */
class JianyanJianchaListController extends Yaf_Controller_Abstract
{
    function IndexAction()
    {
        //显示检查列表，需要以下参数：
        //zhuyuan_id,检查类别：入院检查、住院检查、出院检查
        $request = $this->getRequest();
        $zhuyuan_id = $request->getPost("zhuyuan_id",0);
        $yiyuan_id = $request->getPost("yiyuan_id",0);
        $list_type = $request->getPost("list_type","");
//        $zhuyuan_id = $_REQUEST["zhuyuan_id"];
//        $list_type = $_REQUEST["list_type"];
//        $yiyuan_id = $_REQUEST["yiyuan_id"];
        if(!ctype_digit("$zhuyuan_id"))
        {
            Utility::apiJsonError(20024, '住院ID必须是整型');
        }
        if(!ctype_digit("$yiyuan_id"))
        {
            Utility::apiJsonError(20027, '医院ID必须是整型');
        }

        $LisJianChangInfoModel = new LisJianChaInfoModel();
        if($list_type == "全部")
        {

            $jiancha_result_jianyan  = $LisJianChangInfoModel->getJianchaInfo($zhuyuan_id,$yiyuan_id);
            $jiancha_result_jiancha  = $LisJianChangInfoModel->getPacsJianchaInfo($zhuyuan_id,$yiyuan_id);
            if(count($jiancha_result_jianyan)<=0)
            {
                $jiancha_result = $jiancha_result_jiancha;
            }
            else if(count($jiancha_result_jiancha)<=0)
            {
                $jiancha_result = $jiancha_result_jianyan;
            }
            else
            {
                $jiancha_result = array_merge($jiancha_result_jianyan,$jiancha_result_jiancha);
            }
        }
        else if($list_type == "检查")
        {
            $jiancha_result  = $LisJianChangInfoModel->getPacsJianchaInfo($zhuyuan_id,$yiyuan_id);
        }
        else if($list_type == "检验")
        {
            $jiancha_result  = $LisJianChangInfoModel->getJianchaInfo($zhuyuan_id,$yiyuan_id);
        }

        if(!empty($jiancha_result)&&is_array($jiancha_result)&&count($jiancha_result)>0)
        {
            $data['state'] = '1';
        }
        else
        {
            $data['state'] = '0';
        }
        $data['result'] = $jiancha_result;
        $data['error'] = 200;
        $data['msg'] = "";
        Utility::apiJsonResultExtends($data);
        //Utility::apiJsonResult($data,"",$_REQUEST["compression_http_data"]);
    }
}